<td class="job-link">
  {% if page !== 'build' %}
    <a href="/[[ job.project.name || project.name ]]/[[ job.nojobs ? '' : 'job/' + job._id ]]">
  {% endif %}

  <i ng-hide="job.nojobs"
     data-toggle="tooltip"
     title="[[ job.status ]]"
     class="fa [[ statusClasses[job.status] ]]"></i>
  <span ng-show="job.nojobs">No job history</span>
  <span data-test="job-id">[[ job._id.substr(0,8) ]]</span>

  {% if page !== 'build' %}
    </a>
  {% endif %}
</td>

{% if page !== 'history' %}
  {% if !public && currentUser %}
    <td class="deploy" ng-hide="page === 'build'">
      <span ng-hide="job.running || job.project.access_level < 1"
            ng-click="startDeploy(job)"
            data-toggle="tooltip" title="Retest &amp; Deploy"
            data-delay="200" class="clickable test-and-deploy-action">
        <i class="fa fa-cloud-upload"></i>
      </span>
    </td>

    <td class="refresh" ng-hide="page === 'build'">
      <span ng-hide="job.running || job.project.access_level < 1"
            data-toggle="tooltip"
            ng-click="startTest(job)"
            title="Retest" data-delay="500"
            class="clickable test-only-action">
        <i class="fa fa-refresh"></i>
      </span>
    </td>
  {% endif %}

  <td class="project-name" ng-hide="page === 'build'">
    <a href="/[[ job.project.name || project.name ]]/">
      [[ job.project.display_name ]]
    </a>
  </td>

  <td class="history" ng-hide="page === 'build'">
    <table class='last-builds'>
      <tr>
        <td ng-repeat="pjob in job.project.prev"
            data-toggle="tooltip"
            title="[[ pjob._id.slice(0,8) ]] [[ pjob.status ]]"
            class="build-[[ $index ]] status-[[ pjob.status ]]"></td>
      </tr>
    </table>
  </td>
{% endif %}

<td class="committer">
  <div ng-show="job.trigger.author.image" ng-switch="!!job.trigger.author.url">
    <img ng-switch-when="false" ng-src="[[ job.trigger.author.image ]]" class="img-circle"/>
    <a ng-switch-default href="[[ job.trigger.author.url ]]" target="_blank">
      <img ng-src="[[ job.trigger.author.image ]]" class="img-circle"/>
    </a>
  </div>
</td>

<td class="branch">
  <span>[[ job.ref.branch ]]</span>
</td>

<td class="commit-url" ng-switch="!!job.trigger.url">
  <span ng-switch-when="true">
  {% if page !== "history" %}
    <a href="[[ job.trigger.url ]]" target="_blank">
  {% endif %}

  <span class="small-text pull-left truncate" title="[[ job.trigger.message ]]">
    <i class="trigger-icon fa fa-[[ triggers[job.trigger.type].icon ]]" data-toggle="tooltip" title="[[ triggers[job.trigger.type].title ]]"></i>
    [[ job.trigger.message ]]
  </span>

  {% if page === "history" %}
    <a class="pull-right" href="[[ job.trigger.url ]]" target="_blank">
      <i class="fa fa-external-link"></i>
  {% endif %}
  </a>
  </span>

  <span class="small-text pull-left" ng-switch-default title="[[ job.trigger.message ]]">
    <i class="trigger-icon fa fa-[[ triggers[job.trigger.type].icon ]]" data-toggle="tooltip" title="[[ triggers[job.trigger.type].title ]]"></i>
    [[ job.trigger.message ]]
  </span>
</td>

{% if page !== 'history' %}
  <td class="github-link" ng-hide="page === 'build'">
    <a href="[[ job.project.display_url || project.display_url ]]" target="_blank">
      <i class="fa fa-[[ providers[job.project.provider.id].inline_icon || 'globe' ]]"></i>
    </a>
  </td>
{% endif %}

<td class="run-time" ng-switch="job.status">
  <time ng-switch-when="running" class="duration" since="[[ job.created ]]" ng-hide="job.nojobs"></time>
  <time ng-switch-when="submitted" class="duration" since="[[ job.started ]]" ng-hide="job.nojobs"></time>
  <time ng-switch-default class="duration" duration="[[ job.duration ]]" ng-hide="job.nojobs"></time>
</td>

<td class="finished-at" ng-switch="job.status === 'running'">
  {% if page !== 'history' %}
    <i ng-show="job.status === 'running' || job.status === 'submitted'" data-toggle="tooltip" title="Cancel Job" class="fa fa-times cancel-job" ng-click="cancelJob(job._id)"></i>
  {% endif %}

  <span ng-switch-when="false" class="small-text" ng-hide="job.nojobs || job.status === 'submitted'">
    <time data-toggle="tooltip" data-placement="top" datetime="[[ job.finished ]]" class="timeago summary-text"></time>
    {% if page === 'history' %}
      <i class="fa fa-clock-o summary-icon" data-toggle="tooltip" data-placement="top" title="[[ job.finished ]]"></i>
    {% endif %}
  </span>
  <div ng-switch-when="true" class="progress-meter">
    <div class="progress progress-striped active progress-info">
      <div class="bar" style="width:[[ (phases.indexOf(job.phase)+1)/phases.length*100 ]]%; max-width: 100%"></div>
    </div>
  </div>
</td>

{% if !public && currentUser %}
  <td class="configure" ng-hide="page === 'build'">
    <a href="/[[ job.project.name || project.name ]]/config"
       ng-show="job.project.access_level > 1"
       data-toggle="tooltip" data-delay="500" title="Configure">
      <i class="fa fa-wrench"></i>
    </a>
  </td>
{% endif %}
